package com.yanqu.road.server.manger.activity.platform;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.ePlayerAttrType;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.protocol.GameErrorCode;

import java.util.List;

public class SimpleActivityResult {

    ePlayerAttrType attrType = ePlayerAttrType.Null;

    int ret;

    ActivityInfo activityInfo;

    void check(int type){
        attrType = ePlayerAttrType.forValue(type);
        if(attrType == ePlayerAttrType.Null || !PlatformActivityMgr.isOpenType(attrType)){
            ret = GameErrorCode.E_REQUEST_ARGUMENT_ERROR;
            return;
        }
        List<ActivityInfo> list = NormalActivityMgr.getOpenActivityInfoList(eActivityType.PlatformActivity.getValue(), PlatformActivityMgr.getActivityChildTypeByType(attrType));
        if(list.size() == 0){
            ret = GameErrorCode.E_ACTIVITY_NO_FOUND;
            return;
        }
        activityInfo = list.get(0);
        if(!ActivityMgr.activityInTime(activityInfo)){
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }
    }

}

